package com.ng.desktop.hr.view.cases;

import java.awt.Dimension;
import java.util.Arrays;
import java.util.List;

import com.ng.desktop.hr.model.Cases;
import com.ng.desktop.hr.persistence.CasePersistence;
import com.ng.desktop.hr.services.HRListingService;
import com.ng.desktop.hr.services.NGFactoryBean;
import com.ng.framework.persistence.NGSearchParameter.Type;
import com.ng.framework.persistence.NGSearchParameter.UnaryOperation;
import com.ng.framework.view.desktop.NGABMCFrame;
import com.ng.framework.view.desktop.NGTablePanel;
import com.ng.framework.view.desktop.filters.NGComboFilter;
import com.ng.framework.view.desktop.filters.NGFilter;
import com.ng.framework.view.desktop.filters.NGTextFieldFilter;

public class CaseFrame extends NGABMCFrame<Cases, CasePersistence> {

	private static final long serialVersionUID = -1306560836396996812L;

	public CaseFrame() {
		this.setTitle("Gestión de Casos");
		this.setSize(new Dimension(1024, 600));
		this.centrar();
	}

	@Override
	protected NGTablePanel<Cases, CasePersistence> createTable(CasePersistence persistence) {
		return new CaseTablePanel(persistence);
	}

	@Override
	protected CasePersistence createPersistence() {
		return (CasePersistence) NGFactoryBean.getInstance().getBean("casePersistence");
	}

	@Override
	protected List<NGFilter> createFilters() {

		HRListingService hrListingService = (HRListingService) NGFactoryBean.getInstance().getBean("hrListingService");

		return Arrays.asList(new NGFilter[]{
				new NGTextFieldFilter("Titulo", Cases.class, "title", Type.STRING, UnaryOperation.LIKE),
				new NGTextFieldFilter("Cliente", Cases.class, "customer", Type.STRING, UnaryOperation.LIKE, "fullName"),
				new NGComboFilter("Estado", Cases.class, "caseState", Type.INTEGER, UnaryOperation.EQUALS, hrListingService
						.getList(HRListingService.CASE_STATES)),
				new NGComboFilter("Prioridad", Cases.class, "casePriority", Type.INTEGER, UnaryOperation.EQUALS, hrListingService
						.getList(HRListingService.CASE_PRIORITIES)),
				new NGComboFilter("Contacto", Cases.class, "caseContactType", Type.INTEGER, UnaryOperation.EQUALS, hrListingService
						.getList(HRListingService.CASE_CONTACT_TYPE))});
	}

}
